from tkinter import *
import os


r = Tk()
r.wm_minsize(400, 200)
r.title("磁盘扫描")
t = Text(r, width=100, height=40)
def scan(pa="C:/"):
    r = os.listdir(pa)
    for i in r:
        # 判断是文件还是文件夹
        temp_path = pa + "/" + i
        if os.path.isdir(temp_path):
            try:
                scan(temp_path)
            except (PermissionError, FileNotFoundError):
                continue
        file_info = os.stat(temp_path)
        num = file_info.st_size / 1024 / 1024
        if num > 50:
            t.insert("insert", "文件名：%s,大小为%0.2f %s" % (temp_path, num, "MB")+"\n")


b = Button(r, text="一键扫描", width=8, height=2,command=scan)
b.grid(row=1, column=0)

t.grid(row=2, column=0)

r.mainloop()
